package com.hiraeth.modules.monitor.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hiraeth.common.utils.PageParams;
import com.hiraeth.modules.monitor.dao.MonitorAlertNotificationDao;
import com.hiraeth.modules.monitor.entity.MonitorAlertNotification;
import com.hiraeth.modules.monitor.service.MonitorAlertNotificationService;
import org.springframework.stereotype.Service;

@Service
public class MonitorAlertNotificationServiceImpl extends ServiceImpl<MonitorAlertNotificationDao, MonitorAlertNotification> implements MonitorAlertNotificationService {

    /**
     * 分页查询告警渠道
     *
     * @param pageParams
     * @return
     */
    @Override
    public IPage<MonitorAlertNotification> queryPage(PageParams<MonitorAlertNotification> pageParams) {
        MonitorAlertNotification query = pageParams.mapToObject(MonitorAlertNotification.class);
        QueryWrapper<MonitorAlertNotification> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(ObjectUtils.isNotEmpty(query.getName()), MonitorAlertNotification::getName, query.getName());
        return baseMapper.selectPage(pageParams, queryWrapper);
    }
}
